﻿using System;
using System.Runtime.InteropServices;

namespace QuotationService.RealtimeQuotation
{
    /// <summary>
    /// 行情信息
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    internal struct FutureQuotationInfo
    {
        /// <summary>
        /// 序号
        /// </summary>
        public Int32 SN;

        /// <summary>
        /// 商品代码
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.CodeLength)]
        public string Code;

        /// <summary>
        /// 商品名称
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.NameLength)]
        [ServiceManager.Utils.Encoding("UTF-8")]
        public string Name;

        /// <summary>
        /// 市场
        /// </summary>
        public char ExchId;

        /// <summary>
        /// 行情来源
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MarshalSizeConsts.QuotLevelLength)]
        public string QuotLevel;

        /// <summary>
        /// 10档盘口
        /// </summary>
        [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 5)]
        public OrderBook[] BidAsk;

        /// <summary>
        /// 加权平均卖价
        /// </summary>
        public double SellAvgPrice;

        /// <summary>
        /// 加权平均买价
        /// </summary>
        public double BuyAvgPrice;

        /// <summary>
        /// 内盘
        /// </summary>
        public Int64 InnerVolume;

        /// <summary>
        /// 外盘
        /// </summary>
        public Int64 OuterVolume;

        /// <summary>
        /// 不定盘
        /// </summary>
        public Int64 NotDefineVolume;

        /// <summary>
        /// 逐笔信息
        /// </summary>
        [MarshalAs(UnmanagedType.Struct)]
        public FutureTickInfo Tick;

        /// <summary>
        ///记录更新的时间
        /// </summary>
        public DateTime UpdateTime;

        /// <summary>
        /// 读取行情记录的时间
        /// </summary>
        public DateTime QuotationTime;

    }
}
